how to open a file in read and write mode in perl